<template>
	<view class="box">
		<!-- #ifdef H5|| MP-WEIXIN -->
		<view class="">
			<u-navbar title="分享" :fixed="true" :placeholder="true" :safeAreaInsetTop="true" :autoBack="false"
				leftIconColor="#666" titleStyle="color:#333" bgColor="transparent" @leftClick="leftClick"></u-navbar>
			<image class="indexbg"
				src="https://images.fudiemall.com/storage/default/20250411/BG77ff634c5c493fbb0cb752c7b44d86c703900c11.png"
				mode="aspectFill"></image>
		</view>
		<!-- #endif -->


		<view class="main">
			<u-checkbox-group iconPlacement="right" placement="column" @change="checkboxChangeAll">
				<view class="item" v-for="item in merberlist" :key="item.id">
					<image :src="item.group.avatar" mode="aspectFill"></image>
					<text>{{item.group.name}}</text>
					<u-checkbox v-if="isshow" shape='circle' class="checkitem" size='15' :checked='false'
						activeColor='#FFC300' :name="item.group.hx_group_id.toString()"></u-checkbox>
					<!-- <checkbox v-if="isshow" borderColor="#333" activeBorderColor="#FFC300" class="checkitem"
						activeBackgroundColor="#FFC300" backgroundColor="#f2f2f2" :checked="false"
						:value="item.group.hx_group_id.toString()"></checkbox> -->
				</view>


			</u-checkbox-group>
			<!-- <checkbox-group @change="checkboxChangeAll">
				
			</checkbox-group> --> 
		</view>
		<noDatas :xxxList="merberlist" :showMore="false"></noDatas>

		<view class="empty3">

		</view>
		<view class="empty3">

		</view>

		<view class="btn" @click="right">
			{{righttxt}}
		</view>

		<view style="width: 750rpx;height: 88rpx;">

		</view>
	</view>
</template>

<script>
	import {
		myManageGroup,
		customGroup
	} from "../../api/hx.js"
	import {
		myuser
	} from "../../api/user.js"
	import {
		detail,
		goodsdetail
	} from "../../api/local.js"
	import {
		shopDetail,
	} from "../../api/settled.js"
	import {
		cloudDetail,

	} from "../../api/cloudMall.js"

	export default {
		data() {
			return {
				selectedIds: [],
				isshow: false,
				righttxt: "点击选择",
				word: "",
				merberlist: [],
				groupid: "",
				tit: "",
				groupinfo: "",
				is_admin: "",
				user: {},
				info: {
					type: "",
					id: "",
					image: "",
					price: "",
					stock: "",
					rate: ""
				},
				type: "",
				ids: ""

			}
		},
		onLoad(e) {
			this.ids = e.id
			this.type = e.type
			this.info.type = e.type
			this.info.id = e.id
			this.getlist()
			if (this.type == 1) {
				this.getDetails()
			} else if (this.type == 2) {
				this.getdetail()
			} else if (this.type == 3) {
				this.initGoodsdetail()
			} else if (this.type == 4) {
				this.getdetaildm()
			}
			this.getuser()


		},
		onShow() {


		},
		methods: {
			initGoodsdetail() {
				let data = {
					id: this.ids
				}
				cloudDetail(data).then(res => {
					console.log('详情', res)
					if (res.code == 1) {
						this.info.name = res.data.name
						this.info.image = res.data.thumb
						this.info.price = res.data.min_price
						this.info.stock = res.data.total_stock
					}
				})
			},
			getdetaildm() {
				goodsdetail({
					id: this.ids
				}).then(res => {
					this.info.name = res.data.name
					this.info.image = res.data.image
					this.info.price = res.data.price
					if (res.data.is_stock == 0) {
						this.info.stock = "不限制库存"
					} else {
						this.info.stock = res.data.total_stock
					}
				})
			},
			getDetails() {
				const data = {
					seller_id: this.ids
				}
				shopDetail(data).then(res => {
					console.log(res);
					if (res.code == 1) {
						this.info.rate = res.data.evaluate_rate
						this.info.name = res.data.name
						this.info.image = res.data.cover
					}

				})
			},
			getdetail() {
				detail({
					id: this.ids,
					latitude: uni.getStorageSync("latitude"),
					longitude: uni.getStorageSync("longitude")
				}).then(res => {
					this.info.rate = res.data.evaluate_rate
					this.info.name = res.data.name
					this.info.image = res.data.cover
					// this.canvasDraw(res.data)
				})
			},
			set() {
				uni.showLoading({
					title: "分享中",
					mask: true
				})
				customGroup({
					hx_group_id: this.selectedIds,
					type: this.info.type,
					id: this.info.id,
					rate: this.info.rate,
					name: this.info.name,
					image: this.info.image,
					price: this.info.price,
					stock: this.info.stock
				}).then(res => {
					uni.hideLoading()
					if (res.code == 1) {
						setTimeout(() => {
							uni.navigateBack()
						}, 1000)
					}
					uni.$u.toast(res.msg)
				})
			},
			getuser() {
				myuser().then(res => {
					this.user = res.data
				})
			},
			gomore(item) {
				if (this.is_admin != 0 && this.user.id != item.member_id) {

					uni.setStorageSync("groupitem", item)
					uni.navigateTo({
						url: "/pagesMy/chat/more?id=" + this.groupid
					})

				}
			},
			leftClick() {
				//获取页面栈的长度
				const canNavBack = getCurrentPages()
				console.log(canNavBack.length);
				// 判断是否刷新了浏览器，刷新了浏览器，页面栈只有当前一个
				if (canNavBack.length > 1) {
					uni.navigateBack({
						delta: 1
					})
				} else {
					uni.switchTab({
						url: '/pages/index/cloudCatIndex'
					})
				}
			},
			sub() {
				this.page = 1,
					this.getlist()
			},
			groupdetail() {
				groupDetails({
					hx_group_id: this.groupid
				}).then(res => {
					if (res.code == 1) {
						this.groupinfo = res.data
						this.is_admin = res.data.group_user_one.is_admin
						this.tit = `${this.groupinfo.name}(${this.groupinfo.member_number}人)`
						// console.log("群详情", res)
					} else {
						uni.$u.toast(res.msg)
					}

				})
			},
			getlist() {
				myManageGroup({


				}).then(res => {
					if (res.code == 1) {
						this.merberlist = res.data
						console.log(this.merberlist, "asda")
					}
				})
			},

			right() {
				console.log('点击分享',this.selectedIds.length)
				this.isshow = true
				this.righttxt = "点击分享"
				if (this.selectedIds.length != 0) {
					this.set()
				}
			},
			checkboxChangeAll(e) {
				this.selectedIds = e
				console.log(this.selectedIds)
			},
		},

	}
</script>
<style>
	page {
		background-color: #f7f7f7;
	}
</style>
<style lang="scss">
	.box {
		width: 750rpx;

	}

	.btn {
		width: 696rpx;
		height: 80rpx;
		background: linear-gradient(270deg, #FA2222 2%, #FFC400 98%);
		border-radius: 190rpx 190rpx 190rpx 190rpx;
		font-weight: 500;
		font-size: 36rpx;
		color: #FFFFFF;
		text-align: center;
		line-height: 80rpx;
		position: fixed;
		bottom: 50rpx;
		left: 50%;
		transform: translateX(-50%);
	}

	/deep/.u-navbar__content {
		background: transparent;
	}

	.indexbg {
		position: absolute;
		top: 0;
		left: 0;
		width: 750rpx;
		height: 460rpx;

	}

	/deep/ .u-navbar__content__right__text {
		color: #FF1616;
	}

	.wrap_top {
		width: 750rpx;
	}

	.search {
		width: 690rpx;
		height: 72rpx;
		background: #E0DDDA;
		border-radius: 12rpx 12rpx 12rpx 12rpx;
		margin: 0 auto;
		position: relative;

		>image {
			width: 32rpx;
			height: 30rpx;
			position: absolute;
			top: 22rpx;
			left: 34rpx;

		}

		>input {
			width: 620rpx;
			padding-left: 70rpx;
			height: 72rpx;
			font-weight: 400;
			font-size: 28rpx;
			color: rgba(255, 255, 255, 0.8);
		}
	}

	.main {
		width: 750rpx;

	}

	.item {
		width: 690rpx;
		margin: 0 auto;
		margin-top: 24rpx;
		display: flex;
		align-items: center;
		position: relative;

		>image {
			width: 84rpx;
			height: 84rpx;
			border-radius: 50%;
		}

		>text {
			font-weight: 400;
			font-size: 30rpx;
			color: #333;
			margin-left: 15rpx;
			max-width: 300rpx;
			white-space: nowrap;
			/* 防止文本换行 */
			overflow: hidden;
			/* 隐藏溢出的文本 */
			text-overflow: ellipsis;
			/* 当文本溢出时显示省略号 */
		}

		.tag {
			padding: 5rpx 10rpx 5rpx 10rpx;
			background: #FFC300;
			border-radius: 4rpx 4rpx 4rpx 4rpx;
			opacity: 0.5;
			font-size: 20rpx;
			color: #fff;
			text-align: center;
			margin-left: 20rpx;
		}

		/deep/.uni-checkbox-input {
			width: 30rpx;
			height: 30rpx;
			position: absolute;
			right: 40rpx;
			border-radius: 50%;
		}

		/* #ifdef MP-WEIXIN */

		.checkitem {
			width: 30rpx;
			height: 30rpx;
			position: absolute;
			right: 40rpx;
			border-radius: 50%;

		}

		/* #endif */
		/deep/.u-checkbox {
			width: 30rpx;
			height: 30rpx;
			position: absolute;
			right: 40rpx;
			border-radius: 50%;
		}
	}
</style>